{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fileName:fmt.txt\n"
     ]
    }
   ],
   "source": [
    "fileName = input(\"fileName:\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "modelName:flfy\n"
     ]
    }
   ],
   "source": [
    "modelName = input(\"modelName:\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "Input = \"1\"\n",
    "Select = \"2\"\n",
    "Date = \"3\"\n",
    "Money = \"4\"\n",
    "Rate = \"5\"\n",
    "Area = \"6\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1 = open(fileName,\"r\",encoding='utf-8') #input file with format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "fjq = open(modelName + \".js\",\"a+\",encoding='utf-8') #generate list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "for line in f1:\n",
    "    useless,arr = line.split(':',1)\n",
    "    enName = arr.split()[0]\n",
    "    fjq.write(\"\"\"{1}: $(\"#{0}_{1}\").val(),\"\"\".format(modelName,enName)+'\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fjq.write('\\n\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fjq.write('//list to input\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1 = open(fileName,\"r\",encoding='utf-8') #input file with format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "for line in f1:\n",
    "    useless,arr = line.split(':',1)\n",
    "    enName = arr.split()[0]\n",
    "    if Date == arr.split()[1]:\n",
    "        fjq.write(\"\"\"$(\"#{0}_{1}\").val((rows[0].{1}==null)?null:rows[0].{1}.substring(0,10));\"\"\".format(modelName,enName)+'\\n')\n",
    "    elif Select == arr.split()[1]:\n",
    "        fjq.write(\"\"\"$(\"#{0}_{1}\").setValue(rows[0].{1});\"\"\".format(modelName,enName)+'\\n')\n",
    "    else:\n",
    "        fjq.write(\"\"\"$(\"#{0}_{1}\").val(rows[0].{1});\"\"\".format(modelName,enName)+'\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fjq.write('\\n\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fjq.write('//clear input \\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1 = open(fileName,\"r\",encoding='utf-8') #input file with format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "for line in f1:\n",
    "    useless,arr = line.split(':',1)\n",
    "    enName = arr.split()[0]\n",
    "    if arr.split()[1] == Select:\n",
    "        fjq.write(\"\"\"$(\"#{0}_{1}\").setValue('');\"\"\".format(modelName,enName)+'\\n')\n",
    "    else:\n",
    "        fjq.write(\"\"\"$(\"#{0}_{1}\").val('');\"\"\".format(modelName,enName)+'\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fjq.write('\\n\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fjq.write('//datadict \\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1 = open(fileName,\"r\",encoding='utf-8') #input file with format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "for line in f1:\n",
    "    cnName,arr = line.split(':',1)\n",
    "    enName = arr.split()[0]\n",
    "    propType = arr.split()[1]\n",
    "    if propType == Select:\n",
    "        fjq.write(\"\"\"getDataDict(\"#{0}_{1}\", \"{2}_{3}\"); //{4}\"\"\".format(modelName,enName,modelName.upper(),enName.upper(),cnName) + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "fjq.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
